package ua.com.fesvlast.hotel.tests.dao;

import static org.junit.Assert.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;



import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import ua.com.fesvlast.hotel.model.dao.DAOFactory;
import ua.com.fesvlast.hotel.model.enteties.Orders;
import ua.com.fesvlast.hotel.model.utils.OrderStatus;

public class OrderDaoTest {
	private Orders order ;
	
	@Before
	public void init() throws ParseException{
		
		String datePatern="yyyy.MM.dd HH:mm:ss";
		Date date =Calendar.getInstance().getTime();
		
		SimpleDateFormat simpleDateFormat=new SimpleDateFormat(datePatern);
		String strtime =simpleDateFormat.format(date);
		System.out.println(strtime);
		
		order =new Orders();
		order.setOrderDate(strtime);
		order.setArrivalTime("2014-12-31 11:30:45");
		order.setDepartureTime("2015-01-1 11:30:45");
		order.setComment("It must be nice room!");
		order.setUserId(3);
		order.setHotelRoomId(3);
		
	}

	@Test
	@Ignore
	public void InsertDataIntoOrdersTable(){
		int i=DAOFactory.getOrdersDAO().createOrder(order);
		assertEquals("if data was inserted return true!", true, i>0);
	}
	@Test
	public void getOpenedOrders(){
		
		List<Orders> list =DAOFactory.getOrdersDAO().getListOrders(OrderStatus.OPENED.toString());
		int size=list.size();
		assertEquals("Size should be 3", 3, size);
	}
	
	@Test
	public void getListAdminOrdersTest(){
		List<Map<String, Object>> list =DAOFactory.getOrdersDAO().getListAdminOrder(OrderStatus.OPENED.toString());
		
		assertEquals("The result equals 3",3, list.size());
		
	}
	
	@Test
	public void getCurrentOrderByID(){
		Orders order =DAOFactory.getOrdersDAO().getCurrentOrderByID(12);
		assertEquals("Input id of our order","OPENED",order.getStatus());
	}

}
